package org.example;

import lombok.extern.slf4j.Slf4j;
import org.example.annotation.Test1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@Slf4j
@RestController
public class Main implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        test.method1();
    }

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Autowired
    private Test1 test;

    @GetMapping("echo")
    public boolean echo() {
        boolean isDone = false;
        try {
             test.method1();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            isDone = false;
        } finally {
            log.info("isDone : {}", isDone);
        }
        return isDone;
    }
}